<?php
 /*	$db_host = "localhost";
	$db_user = "root";
	$db_pass = "1234";
	$db_name = "star_fashion";
 */
	$db_host = "localhost";
	$db_user = "root";
	$db_pass = "1234";
	$db_name = "ds_star_fashion";

	mysql_connect($db_host,$db_user,$db_pass); 
	mysql_select_db($db_name);
	mysql_query("SET NAMES utf8");
	
	
	function select($t,$f,$v,$etc = '',$s='*') {
		$v		= urldecode($v);
		$sql	= "SELECT $s FROM $t WHERE $f = '$v' $etc LIMIT 1";
	 
		$query	= mysql_query($sql);
		if(!mysql_num_rows($query)) {
			/*$url = $_SERVER["HTTP_REFERER"] ? $_SERVER["HTTP_REFERER"] : '/';
			header("location: $url");*/
			return array();
		}
		return mysql_fetch_assoc($query);
	}
	
	function product_check($order_data){
		$ppid = array();
		foreach($order_data as $key => $res){
			$sql = "SELECT `product_id`  FROM `tbl_product` WHERE `product_id` = '".$res['product_id']."' AND `status` = '1' LIMIT 1";
			$query	= mysql_query($sql) or die($sql);
			if(!mysql_num_rows($query)) {
				return array();
			}
			$ppid[] = $res['product_id'];
		}
		return $ppid;
	}
	
	function getItem($order_data){
		$item_id = array();
		foreach($order_data as $key => $res){
			$sql = "SELECT `item_id` FROM `tbl_product_item` WHERE `item_id` = '".$res[item_id]."' LIMIT 1";
			$query	= mysql_query($sql) or die($sql);
			if(!mysql_num_rows($query)) {
				return array();
			}
			$item_id[] = $res['item_id'];
		}
		return $item_id;
	}

?>